\section{Webcam Readout}
This section contains information about the implementation of the webcam readout. It provides design choices for the pipeline and test results.

\subsection{Pipeline}
There are several different possibilities to implement the pipeline that is needed to process real-time video. Possible parameters include size of the input video, video format of the input, framerate and video format at the time of processing.

The webcam can output video in two formats: \emph{video/x-raw-yuv} and \emph{image/jpeg}. The first is raw video which takes up more bandwidth of the USB line, but requires less processing power on the Gumstix. The second is more compact, but it is required to convert it to another format before it can be processed on the Gumstix. The choice therefore depends on the bandwidth that is available between Gumstix and the webcam. Testing showed that the Gumstix did not have any problems receiving \emph{x-raw-yuv} format in sizes up to 640x480 at 30 fps, thus the format \emph{x-raw-yuv} was chosen as input format.

The size of the input determines the quality of the video and therefore the quality of image recognition that is possible with it. Because the image recognition that is needed in this assignment is very simple (it amounts to tracking an object of only one color), a high resolution is not needed. Therefore, 160x120 was chosen as input. With this format and resolution, the frame rate was chosen to be 30 fps. This is the maximum available frame rate and leaves enough computation time in the Gumstix.

Possible output formats are \emph{x-raw-yuv} or \emph{rgb} and several other formats are possible. For a simple thing as color recognition \emph{x-raw-yuv} is well suited though. Because this does not require an extra step in the pipeline, it is more efficient than having to convert it to another format.

With these choices, the pipeline looks like figure \ref{fig:pipeline}. This was simple to implement in C with the gstreamer framework.

\begin{figure}
	\centering
		\includegraphics[width=1.00\textwidth]{images/pipeline.png}
	\caption{The pipeline to be implemented in gstreamer}
	\label{fig:pipeline}
\end{figure}


\subsection{Testing}
In order to test the pipeline, a simple processing function was written to calculate the average luminance. Then, the environment of the webcam was changed to provide more or less light. Results showed that the average luminance updated accordingly. For 160x120 resolution, CPU usage was minimal in these tests (under three percent).
